<?php

declare(strict_types=1);

namespace Plugin\Attractions\Inspection\Model\Inspection_plans;

use Hyperf\Database\Model\Relations\HasMany;
use Hyperf\DbConnection\Model\Model;
use Plugin\Attractions\Inspection\Model\Inspection_records\InspectionRecords;

/**
 * @property int $id ID
 * @property string $name
 * @property int $cycle 巡检周期 1每日、2每周、3每月
 * @property array $person 巡检人
 * @property array $devices 巡检设备
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 */
class InspectionPlans extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'inspection_plans';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'cycle', 'name', 'person', 'devices', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'cycle' => 'integer', 'person' => 'array', 'devices' => 'array', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function records(): HasMany
    {
        return $this->hasMany(InspectionRecords::class, 'plan_id', 'id');
    }
}
